<?php $flag = false; ?>
<h2 class='differentAlign'>Search Results</h2>

<!-- THE MAIN CONTENT CLASS-->
<div class='mainContainer'> <!-- Main div for the contain, behaves like a table-->

  <?php if($news){ ?>
    <?php $flag = true; ?>
    <div class="search">
    <h2>News</h2>
    <?php foreach($news as $n){ ?>
      <div class='news'> <!-- Format the news view -->
        <div>
          <a href='<?php echo bu("news/".$n->id); ?>'>
            <img style="width:100px;" src="<?php echo bu('assets/news/'.$n->image); ?>" />
          </a>
        </div>
        <div>
          <h3><a href='<?php echo bu("news/".$n->id); ?>'><?php echo $n->subject; ?></a></h3>
          <div class='date'><?php echo Helpers::customDate($n->created_at); ?></div>
          <p><?php echo substr($n->content,0,540); ?></p>
        </div>
      </div>
    <?php } ?>
    </div>
  <?php } ?>

   <?php if($articles){ ?>
    <?php $flag = true; ?>
    <div class="search">
    <h2>Articles</h2>
    <?php foreach($articles as $article){ ?>
      <div class='news'> <!-- Format the news view -->
        <div>
          <a href='<?php echo bu("news/".$article->id); ?>'>
            <img style="width:100px;" src="<?php echo bu('assets/articles/'.$article->image); ?>" />
          </a>
        </div>
        <div>
          <h3><a href='<?php echo bu("articles/".$article->id); ?>'><?php echo $article->subject; ?></a></h3>
          <div class='date'><?php echo Helpers::customDate($article->created_at); ?></div>
          <p><?php echo substr($article->content,0,540); ?></p>
        </div>
      </div>
    <?php } ?>
    </div>
  <?php } ?>

  <?php if($links){ ?>
    <?php $flag = true; ?>
    <div class="search">
    <h2>Links</h2>
    <?php foreach($links as $link){ ?>
      <div>
        <h3><a href='<?php echo $link->url; ?>'><?php echo $link->title; ?></a></h3>
        <p><?php echo substr($link->description,0,540); ?></p>
      </div>
    <?php } ?>
    </div>
  <?php } ?>

  <?php if($flag == false){ echo "<i>No matches found. Please try different keywords.</i>"; } ?>
</div>